﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSAP
{
    class BeamWithShell
    {
        public static bool Analyze()
        {
            var model = GetModeNet1();
            //创建有限元模型
            if (!model.CreateFEModel(false)) return model.ShowWarningError();
            //求解
            if (!model.DoLinearStaticAnalyze()) return model.ShowWarningError();
            //绘图
            model.ToGraphics(new StructrueChartParam
            {
                DOF = 2,
                isNodeMaxResponseShow = true,
                ChartType = StructureChartType.GeneralStatic,
            });
            return true;
        }

        public static WModelNet GetModeNet1()
        {
            WModelNet model = new WModelNet();
            //int nodeTagFactor = 1000;
            List<double> x_list1 = new List<double> { 0, 1, 2, 3, 4, 5, 6 };
            List<double> x_list2 = new List<double> { 0, 1, 2, 3, 4, 5, 6 };
            List<double> y_list = new List<double> { 0, 0.2 };

            //var nodeTagList = new List<int>();
            //添加单元和节点
            for (int i = 0; i < 7; i++)
            {
                var node1 = model.AddNode(i, x_list1[i], 0, 0);
                var node2 = model.AddNode(7 + i, x_list2[i], 0.2, 0);
            }

            for (int i = 0; i < 6; i++)
            {
                var shell = model.AddShell(i, i + 1, 8 + i, 7 + i, 0.1);
            }

            //添加荷载
            model.AddNodeLoad(6, 2, -1);
            model.AddNodeLoad(13, 2, -1);

            //添加约束
            model.GetNode(0).SetPin();
            model.GetNode(7).SetPin();

            return model;
        }

        public static WModelNet GetModeNet2()
        {
            WModelNet model = new WModelNet();

            model.AddNode(0, 0, 0, 0);
            model.AddNode(7, 0, 0.2, 0);
            model.AddNode(1, 1, 0, 0);
            model.AddNode(8, 1, 0.2, 0);
            model.AddShell(0, 1, 8 , 7 , 0.1);

            //添加荷载
            model.AddNodeLoad(1, 2, -1);
            //model.AddNodeLoad(13, 2, -1);

            //添加约束
            model.GetNode(0).SetPin();
            model.GetNode(7).SetPin();

            return model;
        }
    }
}
